import { Injectable } from '@angular/core';
import {Repository,FrameContext} from '@farris/devkit';
import { BefRepository, ResponseInfo } from '@farris/bef';

@Injectable()
export class SbssLuStandSelectFrmControllerService {
  constructor(
    private frameContext: FrameContext
  ) {}

  /**
   * 选择点击事件
   * @remarks 
   * @returns 
   */
  toolBarItemClick(): any {
    // 当前的列表
    let standName = this.frameContext.uiState['standName']
    standName = standName + '_sbsslustandselect_data-grid-component';
    let checkedlist = this.frameContext.appContext.componentManager.get([standName,'dataGrid']).checkeds
    this.frameContext.uiState.setPropertyValue('checkedList',checkedlist)
  }


  /**
   * 过滤已筛选
   * @remarks 
   * @returns 
   */
  filterChecked():any{
    let checkedlist = this.frameContext.appContext.componentManager.get(['sbssLuPlanDetail-rpzy-component_sbssluplandetail_rhmx-uc8v-component','rhmx-uc8v-dataGrid'])
    let checkData = checkedlist.data.map(i=>i.lustand.lustand)

    let standName = 'sbssLuStandSelect-vukd-component_sbsslustandselect_data-grid-component';
    let standDataGrid = this.frameContext.appContext.componentManager.get([standName,'dataGrid'])
    
    standDataGrid.data.forEach( i=>{
      checkData.some(c => {
        if(i.id == c){
          standDataGrid.checkRow(i.id)
          return true
       }
       return false
      })

    })

  }
}
